package com.kws.system.controller.Payment;

import com.kws.common.core.domain.R;
import com.kws.system.domain.payment.TbAddressData;
import com.kws.system.domain.payment.rq.UploadContractFileRq;
import com.kws.system.service.payment.UnionPaySigningService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <b>UnionPaySigningController</b>
 *
 * @description: UnionPaySigningController <br>
 * @date: 2024/12/11 09:41 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */

@Api(tags = "银联自助签约")
@RestController
public class UnionPaySigningController {
    private static final Logger logger = LoggerFactory.getLogger(UnionPaySigningController.class);

    @Autowired
    private UnionPaySigningService unionPaySigningService;


    @ApiOperation("查询省市区行业数据")
    @GetMapping("/query/addressData/byType")
    public R<List<TbAddressData>> queryAddressDataByType(@RequestParam String type){
        List<TbAddressData> resultList = unionPaySigningService.queryAddressDataByType(type);
        return R.ok(resultList);
    }

    @ApiOperation("查询所属支行信息")
    @GetMapping("/query/subBranch")
    public R querySubBranch(@RequestParam String areaCode,@RequestParam String key) throws Exception {
        return unionPaySigningService.querySubBranch(areaCode,key);
    }

    @ApiOperation("上传图片")
    @PostMapping("/upload/file")
    public R uploadFile(@RequestParam("file") MultipartFile file) throws Exception {
        return unionPaySigningService.uploadFile(file);
    }

    @ApiOperation("上传详细档案资料")
    @PostMapping("/upload/signContract")
    public R uploadSignContract(@RequestBody UploadContractFileRq rq) throws Exception {
        return unionPaySigningService.uploadSignContract(rq);
    }


    @ApiOperation("根据自助签约流水号发起前台签约")
    @GetMapping("/create/signContract")
    public R createSignContract(@RequestParam String umsRegId,@RequestParam(defaultValue = "PC") String channel) throws Exception {
        return unionPaySigningService.createSignContract(umsRegId,channel);
    }

    @ApiOperation("根据自助签约平台流水号查询入网状态")
    @GetMapping("/query/signContract/status")
    public R querySignContractStatus(@RequestParam String umsRegId) throws Exception {
        return unionPaySigningService.querySignContractStatus(umsRegId);
    }
}
